package com.sino.operation.service.business;

import cn.hutool.core.util.ObjectUtil;
import com.sino.operation.param.out.CenterDataAccount;
import com.sino.operation.param.out.EscReceiveByCounterToAccount;
import com.sino.operation.vo.current.FieldInformation;
import com.sino.operation.vo.current.InfoInput;
import org.aspectj.weaver.ast.Var;
import org.springframework.stereotype.Service;

import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName AccountStartTest
 * @Description TOD
 * @Author 北陈
 * @Date 2021/11/6 21:17
 * @Version 1.0
 */
@Service
public class AccountStartTest {

    public Map getMap(EscReceiveByCounterToAccount escReceiveByCounterToAccount){
        Map<String, Object> mapResult = new HashMap<>();

        Map<String, Object> map = new HashMap<>();
        CenterDataAccount centerDataAccount = escReceiveByCounterToAccount.getEscBodyByAccount().getCenterDataAccount();
        List<InfoInput> infoInputs = centerDataAccount.getInfoInputs();
        infoInputs.forEach(infoInput -> {
            if (ObjectUtil.isNotNull(infoInput)){
                //要将数组信息的集合排除在外
                List<FieldInformation> listFieldInformation = infoInput.getListFieldInformation();
                if (ObjectUtil.isNotNull(listFieldInformation)){
                    listFieldInformation.forEach(fieldInformation -> {
                        if (ObjectUtil.isNotNull(fieldInformation)){
                            String englishName = fieldInformation.getEnglishName();
                            String fieldValue = fieldInformation.getFieldValue();
                            if (ObjectUtil.isNotNull(englishName)){
                                if (ObjectUtil.isNotNull(fieldValue)){
                                    map.put(englishName,fieldValue);
                                }else {
                                    map.put(englishName,null);
                                }
                            }
                        }
                    });
                }
            }

        });

        return map;
    }
}
